@model Lense.com.Models.ImageUploadModels
@{
    ViewBag.Title = "ImageUpload";
    var imagepath = (string)TempData["ImageUrl"];
    Layout = "~/Views/Shared/_Layout_M.cshtml";
}
<link href="@Url.Content("~/Content/themes/base/jquery-ui.css")" rel="stylesheet" />
<link href="@Url.Content("~/Content/CSS/upload_page.css")" rel="stylesheet" />
<link href="@Url.Content("~/Content/CSS/specialist_page.css")" rel="stylesheet" type="text/css" />
<style type="text/css">
    #coll_panel_heading
    {
        font-family: Arial, Helvetica, sans-serif;
        font-size: 14px;
        color: #333333;
        font-weight: bold;
        padding-bottom: 1px;
    }

    .labelSend
    {
        color: green;
    }

    #btnSendTo
    {    
        background-image: url(@Url.Content("~/Content/images/submit.png"));
        background-position: 0px 0px;
        background-repeat: no-repeat;       
        border: 0px;
        cursor: pointer;
        color: transparent;
        background-color: transparent;
    }

    #btnSubmit
    {    
        background-image: url(@Url.Content("~/Content/images/choose_photos_icon.png"));
        background-position: 0px 0px;
        background-repeat: no-repeat;
        width: 33px;
        height: 32px;
        border: 0px;
        cursor: pointer;
        color: transparent;
        background-color: transparent;
    }

    #btnUpload
    {
        background-image: url(@Url.Content("~/Content/images/audioupload.png"));
        background-position: 0px 0px;
        background-repeat: no-repeat;
           width: 40px;
        height: 36px;
        border: 0px;
        cursor: pointer;
        color: transparent;
        background-color: transparent;
    }
</style>
<script src="@Url.Content("~/Scripts/jquery-ui-1.8.20.min.js")"></script>
<script src="http://jquery-ui.googlecode.com/svn/tags/latest/ui/minified/jquery-ui.min.js" type="text/javascript"></script>
<script type="text/javascript" src="@Url.Content("~/Scripts/ddpowerzoomer.js")"></script>
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="0">
<meta http-equiv="Cache-Control" content="no-cache">
<script type="text/javascript">

    function checkfile(sender) {
        var validExts = new Array(".jpg", ".png", ".jpeg", ".gif");
        var fileExt = sender.value;
        fileExt = fileExt.substring(fileExt.lastIndexOf('.'));
        if (validExts.indexOf(fileExt) < 0) {
            alert("Please select a valid image file. Supporting formats are : " +
                     validExts.toString() + " types.");
            return false;
        }
        else return true;
    }

    window.history.forward()
    jQuery(document).ready(function ($) { //fire on DOM ready
        jQuery('#image').addpowerzoom()
        return false;
    })

    jQuery(function () {
        jQuery("#accordion").accordion({
            collapsible: true
        });
    });

    function uploadFile() {
        var filename = jQuery('#Browse').val();
        if (filename == '') {
            alert('Please select file');
            return false;
        }
        else {
            input = document.getElementById('Browse');
            var validExts = new Array(".jpg", ".png", ".jpeg", ".gif");
            var fileExt = filename;
            fileExt = fileExt.substring(fileExt.lastIndexOf('.'));
            if (validExts.indexOf(fileExt) < 0) {
                alert("Please select a valid image file. Supporting formats are : " +
                         validExts.toString() + " types.");
                return false;
            }          
        }
    }
    function AudiouploadFile() {
        var filename = jQuery('#AudioBrowse').val();
        if (filename == '') {
            alert('Please select file');
            return false;
        }
        else {
            input = document.getElementById('AudioBrowse');
            var validExts = new Array(".mp3", ".wav");
            var fileExt = filename;
            fileExt = fileExt.substring(fileExt.lastIndexOf('.'));
            if (validExts.indexOf(fileExt) < 0) {
                alert("Please select a valid audio file. Supporting formats are : " +
                         validExts.toString() + " types.");
                return false;
            }
            if (input.files[0]) {
                file = input.files[0];
                if (file.size > 2197025) {
                    alert("File Duration should not more than 2 minutes.");
                    return false;
                }
                else {
                    return true;
                }
            }
        }
    }

    jQuery(function () {
        jQuery('#btnSendTo').click(function () {
            var checkboxes = jQuery(this).closest('form').find(':checkbox');
            for (var i = 0; i < checkboxes.length; i++) {
                if (checkboxes[i].checked)
                    return true;
            }
            alert("Please select any one group");
            return false;
        });
    });
</script>
@using (Html.BeginForm("Upload", "ImageUpload", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
@*  @Html.AntiForgeryToken()
    @Html.ValidationSummary(true)
    *@<div id="problems">
        <div id="upload_heading_bg_float_space">
            <div id="upload_heading_bg_float">
                <img src="@Url.Content("~/Content/images/home_heading_bg_left.png")" alt="" />
            </div>
            <div id="upload_heading_bg">
                <div id="upload_text">Image Upload</div>
            </div>
            <div id="upload_heading_bg_float">
                <img src="@Url.Content("~/Content/images/home_heading_bg_right.png")" alt="" />
            </div>
        </div>
        <table>
            <tr>
                <td colspan="2" style="padding-left: 15px; padding-top: 20px;">
                    <input type="file" name="FileUpload" onchange="checkfile(this);" accept="image/jpeg,image/png,image/jpeg,jpg|png|jpeg"
                        style="width: 250px; color: ActiveBorder; background: center;" multiple="multiple" id="Browse" />
                    <span style="padding-left: 25px; padding-top: 20px;">
                        <input type="submit" id="btnSubmit" name="Command" value="Upload" onclick="return uploadFile();" /></span>
                </td>
                @if (!string.IsNullOrEmpty(ViewBag.SuccessMsg))
                {
                    <td>
                        <b><span id="successMsg" style="color: red">File uploaded successfully</span></b>
                    </td>
                }
            </tr>
            <tr>
                <td style="padding-left: 15px; padding-top: 20px;">
                    <input type="file" name="AudioFileUpload" accept=".mp3"
                        style="width: 250px; color: ActiveBorder; background: center;" id="AudioBrowse" />
                    <span style="padding-left: 25px; padding-top: 20px;">
                        <input type="submit" id="btnUpload" name="Command" value="Audio Upload" onclick="return AudiouploadFile();" />
                </td>
                @if (!string.IsNullOrEmpty(ViewBag.SuccessMsgAudio))
                {
                    <td style="padding-left: 15px; padding-top: 20px;">
                        <b><span id="successMsg" style="color: red">File uploaded successfully</span></b>
                    </td>
                }
            </tr>
            <tr>
                <td style="padding-left: 15px; padding-top: 20px;">
                    @Html.Label("lblCrop", "Crop"): @Html.DropDownListFor(m => m.CropId, new SelectList(Model.CropsListItems, "Value", "Text"), new { @style = "width:150px;padding-top:3px;padding-bottom:3px;" })
                    @Html.ValidationMessageFor(m => m.CropId)
                </td>
                <td style="padding-top: 20px;"></td>
                <td>
                    @*@Html.DropDownList("ddlCrop", Model.CropList)*@
                </td>
            </tr>
            <tr>
                <td style="padding-left: 15px; padding-top: 20px;">
                    <img  id="image" src="@Url.Content(@imagepath)"  width ="440" height="240" />
                </td>
            </tr>
            <tr>
                <td style="padding-left: 15px; padding-top: 20px;">
                    <table style="empty-cells: hide">
                        <tr>
                            @foreach (var item in Model.ImageList)
                            {       
                                <td>
                                    <a href="@Url.Action("ImagePaging", "ImageUpload", new { ImgUrl = item.ImageUrl })" >
                                        <img src="@Url.Content(item.ImageUrl)"  style="border-color:silver;border-width:3px;" height="30" width="42" /></a>
                                </td>          
                                <td></td>            }
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td style="padding-left: 15px; padding-top: 20px;">
                    <div id="accordion" style="width: 275px">
                        <h1><a href="#">
                            <div id="coll_panel_heading">More Crop Information</div>
                        </a></h1>
                        <div>
                            <table>
                                <tr>
                                    <td style="text-align: left;">
                                        @Html.Label("lblSoil", "Soil")
                                    </td>
                                    <td style="text-align: left;">:
                                    </td>
                                    <td style="padding-left: 12px;">
                                        @*@Html.DropDownList("ddlSoil", Model.SoilList)*@
                                        @Html.DropDownListFor(m => m.SoilId, new SelectList(Model.SoilListItems, "Value", "Text"), new { @style = "width:150px;padding-top:3px;padding-bottom:3px;" })
                                    </td>
                                </tr>
                                <tr>
                                    <td style="text-align: left;">
                                        @Html.Label("lblIrrigation", "Irrigation")
                                    </td>
                                    <td style="text-align: left;">:
                                    </td>
                                    <td style="padding-left: 12px;">
                                        @*@Html.DropDownList("ddlIrratation", M`odel.IrratationList)*@
                                        @Html.DropDownListFor(m => m.IrratationId, new SelectList(Model.IrrigationListItems, "Value", "Text"), new { @style = "width:150px;padding-top:3px;padding-bottom:3px;" })
                                    </td>
                                </tr>
                                <tr>
                                    <td style="text-align: left;">
                                        @Html.Label("lblSeverity", "Severity")
                                    </td>
                                    <td>:
                                    </td>
                                    <td style="padding-left: 12px;">
                                        @*@Html.DropDownList("ddlSeverity", Model.SeverityList)*@
                                        @Html.DropDownListFor(m => m.SeverityId, new SelectList(Model.SeverityListItems, "Value", "Text"), new { @style = "width:150px;padding-top:3px;padding-bottom:3px;" })
                                    </td>
                                </tr>
                                <tr>
                                    <td style="text-align: left;">
                                        @Html.Label("lblPriorty", "Priorty")
                                    </td>
                                    <td>:
                                    </td>
                                    <td style="padding-left: 12px;">
                                        @*@Html.DropDownList("ddlPriorty", Model.PriorityList)*@
                                        @Html.DropDownListFor(m => m.PriortyId, new SelectList(Model.PriortyListItems, "Value", "Text"), new { @style = "width:150px;padding-top:3px;padding-bottom:3px;" })
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        @Html.Label("lblSeason", "Season")
                                    </td>
                                    <td>:
                                    </td>
                                    <td style="padding-left: 12px;">
                                        @Html.DropDownListFor(m => m.SeasonId, new SelectList(Model.SeasonsListItems, "Value", "Text"), new { @style = "width:150px;padding-top:3px;padding-bottom:3px;" })
                                    </td>
                                </tr>
                            </table>
                        </div>

                    </div>
                </td>
            </tr>
            <tr>
                <td style="padding-left: 15px; padding-top: 20px;">
                    <div id="coll_panel_heading">Observation : </div>
                </td>
            </tr>
            <tr>
                <td style="padding-left: 15px; padding-top: 10px;">
                    @Html.TextAreaFor(x => x.TextAreaObservations, new { style = "width: 420px; height: 100px;" })
                </td>
            </tr>
            <tr>
                <td style="padding-left: 15px; padding-top: 20px;">
                    @Html.Label("lblMobileNo", "Mobile NO") : @Html.TextBox("txtMobileNo")
                </td>
            </tr>
            @foreach (var item in Model.GroupList)
            {
                <tr>
                    <td style="padding-left: 80px; padding-top: 5px;">
                        @Html.CheckBox(item.GroupId.ToString(), false, new { id = item.GroupId, name = item.GroupName })@item.GroupName
                    </td>
                </tr>
            }
            <tr>
                <td style="padding-left: 80px; padding-top: 10px;">
                    <input type="submit" id="btnSendTo" name="Command" value="SendTo" style="width: 76px; height: 22px;" /></td>
                @if (!string.IsNullOrEmpty(ViewBag.SuccessShare))
                {
                    <td style="padding-left: 15px; padding-top: 20px;">
                        <b><span id="successMsg" style="color: red">Shared successfully</span></b>
                    </td>
                }
            </tr>
        </table>
    </div>
}
